package org.lgiavedoni.android.franq.core.prediction.strategy.imp;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import org.lgiavedoni.android.franq.core.envent.Event;
import org.lgiavedoni.android.franq.core.envent.dao.EventDao;
import org.lgiavedoni.android.franq.core.prediction.PredictableEvent;
import org.lgiavedoni.android.franq.core.prediction.rule.PredictionRule;
import org.lgiavedoni.android.franq.core.prediction.rule.dao.PredictionRuleDAO;
import org.lgiavedoni.android.franq.core.prediction.rule.imp.PredictionRuleEventDay;
import org.lgiavedoni.android.franq.core.prediction.strategy.PredictionStrategy;
import org.lgiavedoni.android.franq.event.CheckInEvent;
import org.lgiavedoni.android.franq.util.date.DateUtil;

public class NextDayPredictionStrategy implements PredictionStrategy {

	private final EventDao eventDao = EventDao.inst;
	private final PredictionRuleDAO predictionRuleDAO = PredictionRuleDAO.inst;

	@Override
	public List<PredictionRule> generateNewRules() {
		List<PredictionRule> l = new ArrayList<PredictionRule>();

		for (Event e : eventDao.getAll()) {
			// Very basic rule: Tomorrow will be the same
			if (e instanceof CheckInEvent) {
				PredictionRuleEventDay pr = new PredictionRuleEventDay((PredictableEvent) e);
				pr.setHourOfDay(DateUtil.getField(e.getCreationDate(), Calendar.HOUR_OF_DAY));
				pr.setMinutes(DateUtil.getField(e.getCreationDate(), Calendar.MINUTE));
				pr.addDayOfWeek(DateUtil.getField(e.getCreationDate(), Calendar.DAY_OF_WEEK) + 1);

				l.add(pr);
			}
		}
		return l;
	}

	@Override
	public void updatePredictionRuleOcurrences() {
		// TODO Auto-generated method stub
	}

}
